package com.itheima.sh.user.service;

import com.itheima.sh.pojo.User;
import com.itheima.sh.user.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;

    public User queryById(String username) {

       // System.out.println("service....");
        log.info("service....");
//        int i = 1 / 0;
//        try {
//            Thread.sleep(5000);
////            int i = 1 / 0;
////            log.error("this is error111");
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//            log.error("this is error");
//        }

        log.debug("UserService queryById username= {}", username);

        return userMapper.findById(username);
    }

    public User list(String username, String name) {
        return userMapper.findAll(username, name);
    }

}
